# encoding: utf-8
from functools import wraps
from flask import session, redirect, url_for, g


def login_required(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        if hasattr(g, 'user'):
            return func(*args, **kwargs)
        else:
            return redirect(url_for('login'))

    return wrapper
